#  数据分析案例
"""
数据定义的类
"""

import json


class Record:

    def __init__(self, data, order_id, money, province):
        self.data = data  # 为变量赋值（创建变量并赋值)  日期
        self.order_id = order_id  # 订单序号
        self.money = money  # 订单金额
        self.province = province  # 省份


class FileReader:

    def reader_data(self) -> list[Record]:
        """读取文件数据，将读取到的数据转化为Record对象，并将它们封装到列表中储存"""
        pass


class TextReader(FileReader):

    def __init__(self, path):
        self.path = path

    def reader_data(self) -> list[Record]:
        f = open(self.path, "r", encoding="UTF-8")
        record_list = []
        for line in f.readlines():
            line = line.strip()
            data_list = line.split(",")
            record = Record(data_list[0], data_list[1], data_list[2], data_list[3])
            record_list.append(record)
        f.close()
        return record_list


class JsonFileReader(FileReader):

    def __init__(self, path):
        self.path = path

    def reader_data(self):
        f = open(self.path, "r", encoding="UTF-8")
        data_dict = json.loads(f.read())
        print(data_dict)





